if ( !hvm_initialize_guest_resources(v) )
return -EINVAL;
-
- hvm_switch_on = 1;
}
update_pagetables(v);
CTXT_SWITCH_STACK_BYTES);
unlazy_fpu(p);
save_segments(p);
+ if ( HVM_DOMAIN(p) )
+ hvm_load_msrs();
}
if ( !is_idle_vcpu(n) )
set_int80_direct_trap(n);
switch_kernel_stack(n, cpu);
}
+ else
+ {
+ hvm_restore_msrs(next);
+ }
}
if ( p->domain != n->domain )
/* Re-enable interrupts before restoring state which may fault. */
local_irq_enable();
- if ( HVM_DOMAIN(next) )
- {
- hvm_restore_msrs(next);
- }
- else
+ if ( !HVM_DOMAIN(next) )
{
load_LDT(next);
load_segments(next);
- if ( HVM_DOMAIN(next) )
- hvm_load_msrs(next);
}
}
#include <public/hvm/hvm_info_table.h>
int hvm_enabled = 0;
-int hvm_switch_on = 0;
unsigned int opt_hvm_debug_level = 0;
integer_param("hvm_debug", opt_hvm_debug_level);
* are not modified once set for generic domains, we don't save them,
* but simply reset them to the values set at percpu_traps_init().
*/
-void svm_load_msrs(struct vcpu *n)
+void svm_load_msrs(void)
{
struct svm_msr_state *host_state = &percpu_msr[smp_processor_id()];
int i;
- if ( !hvm_switch_on )
- return;
-
while ( host_state->flags )
{
i = find_first_set_bit(host_state->flags);
* are not modified once set for generic domains, we don't save them,
* but simply reset them to the values set at percpu_traps_init().
*/
-void vmx_load_msrs(struct vcpu *n)
+void vmx_load_msrs(void)
{
struct vmx_msr_state *host_state = &percpu_msr[smp_processor_id()];
int i;
- if ( !hvm_switch_on )
- return;
-
while ( host_state->flags )
{
i = find_first_set_bit(host_state->flags);
void (*load_cpu_guest_regs)(struct vcpu *v, struct cpu_user_regs *r);
#ifdef __x86_64__
void (*save_segments)(struct vcpu *v);
- void (*load_msrs)(struct vcpu *v);
+ void (*load_msrs)(void);
void (*restore_msrs)(struct vcpu *v);
#endif
void (*store_cpu_guest_ctrl_regs)(struct vcpu *v, unsigned long crs[8]);
}
static inline void
-hvm_load_msrs(struct vcpu *v)
+hvm_load_msrs(void)
{
if (hvm_funcs.load_msrs)
- hvm_funcs.load_msrs(v);
+ hvm_funcs.load_msrs();
}
static inline void
} while (0)
extern int hvm_enabled;
-extern int hvm_switch_on;
enum { HVM_COPY_IN = 0, HVM_COPY_OUT };
extern int hvm_copy(void *buf, unsigned long vaddr, int size, int dir);